#pragma once

#include "../umlmodel_global.h"

#include <memory>
#include <vector>

#include "ConnectableElement.h"
#include "MultiplicityElement.h"

using std::make_shared;
using std::shared_ptr;
using std::vector;

namespace uml {
class Action;
class Activity;
class StructuredActivityNode;

/// <summary>
/// Variable
/// A Variable is a ConnectableElement that may store values during the execution of
/// an Activity. Reading and writing the values of a Variable provides an
/// alternative means for passing data than the use of ObjectFlows. A Variable may
/// be owned directly by an Activity, in which case it is accessible from anywhere
/// within that activity, or it may be owned by a StructuredActivityNode, in which
/// case it is only accessible within that node.
/// </summary>
class UMLMODEL_EXPORT Variable : public ConnectableElement, public MultiplicityElement {

public: // JsonSerializable override
    void fromJson(const QJsonObject& json, QStringList& errorList) override;
    void toJson(QJsonObject& json) override;

public: // Methods
    /// <summary>
    /// isAccessibleBy
    /// A Variable is accessible by Actions within its scope (the Activity or
    /// StructuredActivityNode that owns it).
    /// </summary>
    virtual bool isAccessibleBy(shared_ptr<Action> a) const;

public: // Properties
    /// <summary>
    /// activityScope getter
    /// An Activity that owns the Variable.
    /// </summary>
    shared_ptr<Activity> activityScope() const;

    /// <summary>
    /// activityScope setter
    /// An Activity that owns the Variable.
    /// </summary>
    void setActivityScope(shared_ptr<Activity> value);

    /// <summary>
    /// scope getter
    /// A StructuredActivityNode that owns the Variable.
    /// </summary>
    shared_ptr<StructuredActivityNode> scope() const;

    /// <summary>
    /// scope setter
    /// A StructuredActivityNode that owns the Variable.
    /// </summary>
    void setScope(shared_ptr<StructuredActivityNode> value);

private: // Fields
    /// <summary>
    /// activityScope
    /// An Activity that owns the Variable.
    /// </summary>
    shared_ptr<Activity> activityScope_;

    /// <summary>
    /// scope
    /// A StructuredActivityNode that owns the Variable.
    /// </summary>
    shared_ptr<StructuredActivityNode> scope_;

};

} // namespace uml
